home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Lines Curves and Area Fills / SineCurve / SineCurve.cs next >
Encoding:
Text File  |  2001-01-15  |  818 b   |  31 lines

  1. //----------------------------------------
  2. // SineCurve.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class SineCurve: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new SineCurve());
  13.      }
  14.      public SineCurve()
  15.      {
  16.           Text = "Sine Curve";
  17.      }
  18.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  19.      {
  20.           PointF[] aptf = new PointF[cx];
  21.  
  22.           for (int i = 0; i < cx; i++)
  23.           {
  24.                aptf[i].X = i;
  25.                aptf[i].Y = cy / 2 * (1 - (float) 
  26.                                    Math.Sin(i * 2 * Math.PI / (cx - 1)));
  27.           }
  28.           grfx.DrawLines(new Pen(clr), aptf);
  29.      }
  30. }
  31.